func subarraySum(nums []int, k int) int {
	ans, pre := 0, 0
	mp := make(map[int]int)
	mp[0] = 1
	for i := 0; i < len(nums); i++ {
		pre += nums[i]
		if v, ok := mp[pre-k]; ok {
			ans += v
		}
		mp[pre]++
	}
	return ans
}
